import { createApp } from 'vue';
import Message from '../components/Message.vue';
type MesssageType = 'success' | 'error' | 'warning' | 'info' | 'default';

export default (message: string, type: MesssageType, duration = 2000) => {
    const ins = createApp(Message, { message, type });

    // 动态创建挂载点
    const mountNode = document.createElement('div');
    document.body.appendChild(mountNode);
    ins.mount(mountNode);

    setTimeout(() => {
        document.body.removeChild(mountNode);
        ins.unmount(mountNode);
    }, duration);
};
